﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows;

namespace Caca.MineSweeper.Win
{
    public class PlotDataTemplateSelector : DataTemplateSelector
    {
        public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container)
        {
            if (item == null)
                return null;

            var window = Application.Current.MainWindow;

            string resourceKey = string.Empty;

            if (item is CoveredPlot)
            {
                resourceKey = "CoveredPlot";
            }
            else if (item is MarkedPlot)
            {
                resourceKey = "MarkedPlot";
            }
            else if (item is NonMinePlot)
            {
                resourceKey = "NonMinePlot";
            }
            else if (item is MinePlot)
            {
                resourceKey = "MinePlot";
            }

            var result = window.FindResource(resourceKey) as DataTemplate;
            return result;
        }
    }
}
